<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 输入年月日,月份和日期输入错误都要重输入(月份在1-12之间,
        // 日期在1到当月最大天数之间).最后输出年月日.
        var year = prompt(`请输入年份`)
        var month = prompt(`请输入月份`)
        while (month < 1 || month > 12) {
            month = prompt(`请重新输入月份`)
        }
        if (year % 100 == 0 && year % 4 == 0 || year % 400 == 0) {
            var day = prompt(`请输入日期`)
            if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
                //alert(`31天`)
                while (day < 1 || day > 31) {
                    day = prompt(`请重新输入日期`)
                }
            } else if (month == 2) {
                //alert(`29天`)
                while (day < 1 || day > 29) {
                    day = prompt(`请重新输入日期`)
                }
            }  else {
                //alert(`30天`)
                while (day < 1 || day > 30) {
                    day = prompt(`请重新输入日期`)
                }
            }
        } else {
            var day = prompt(`请输入日期`)
            if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
                //alert(`31天`)
                while (day < 1 || day > 31) {
                    day = prompt(`请重新输入日期`)
                }
            } else if (month == 2) {
                //alert(`28天`)
                while (day < 1 || day > 28) {
                    day = prompt(`请重新输入日期`)
                }
            }  else {
                //alert(`30天`)
                while (day < 1 || day > 30) {
                    day = prompt(`请重新输入日期`)
                }
            }
       }
       alert(`${year}年，${month}月，${day}日`)
    </script>
</head>

<body>

</body>

</html>